<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>文章管理</title>
<meta name="decorator" content="default" />
<script>
    function viewComment(href){
    	top.dialog({
			title : '查看评论',
			url : href,
			width : $(top.document).width()-220,
			height : $(top.document).height()-180,
			button : [{
				value : '确定',
				callback: function () {
				}
			}]
		}).show();
        return false;
    }
    function page(n,s){
        $("#pageNo").val(n);
        $("#pageSize").val(s);
        $("#searchForm").submit();
        return false;
    }
</script>
</head>
<body>
    <ul class="nav nav-tabs mb-2">
        <li class="active"><a href="${ctx}/cms/article/?category.id=${article.category.id}">文章列表</a></li>
        <shiro:hasPermission name="cms:article:edit">
            <li><a href="<c:url value='${fns:getAdminPath()}/cms/article/form?id=${article.id}&category.id=${article.category.id}'><c:param name='category.name' value='${article.category.name}'/></c:url>">文章添加</a></li>
        </shiro:hasPermission>
    </ul>
    <div class="container-fluid">
        <form:form id="searchForm" modelAttribute="article" action="${ctx}/cms/article/" method="post" class="breadcrumb form-inline form-search">
            <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}" />
            <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}" />
            <div class="row">
                <div class="form-group">
                    <label>栏目：</label>
                    <sys:treeselect id="category" name="category.id" value="${article.category.id}" labelName="category.name" labelValue="${article.category.name}"
                        title="栏目" url="/cms/category/treeData" module="article" notAllowSelectRoot="false" cssClass="form-control" />
                </div>
                <div class="form-group">
                    <label>标题：</label>
                    <form:input path="title" htmlEscape="false" maxlength="50" class="form-control" />
                </div>
                <div class="form-group">
                    <input id="btnSubmit" class="btn btn-primary" type="submit" value="查询" />
                </div>
                <div class="form-group">
                    <label>状态：</label>
                    <form:radiobuttons onclick="$('#searchForm').submit();" path="delFlag" items="${fns:getDictList('cms_del_flag')}" itemLabel="label" itemValue="value" htmlEscape="false" />
                </div>
            </div>
        </form:form>
        <sys:message content="${message}" />
        <table id="contentTable" class="table table-striped table-bordered">
            <thead>
                <tr>
                    <th>栏目</th>
                    <th>标题</th>
                    <th>权重</th>
                    <th>点击数</th>
                    <th>发布者</th>
                    <th>更新时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                <c:forEach items="${page.list}" var="article">
                    <tr>
                        <td><a href="javascript:void(0);" onclick="$('#categoryId').val('${article.category.id}');$('#categoryName').val('${article.category.name}');$('#searchForm').submit();return false;">${article.category.name}</a></td>
                        <td><a href="${ctx}/cms/article/form?id=${article.id}" title="${article.title}">${fns:abbr(article.title,40)}</a></td>
                        <td>${article.weight}</td>
                        <td>${article.hits}</td>
                        <td>${article.user.name}</td>
                        <td><fmt:formatDate value="${article.updateDate}" type="both" /></td>
                        <td><a href="${pageContext.request.contextPath}${fns:getFrontPath()}/view-${article.category.id}-${article.id}${fns:getUrlSuffix()}" target="_blank">访问</a>
                            <shiro:hasPermission name="cms:article:edit">
                                <c:if test="${article.category.allowComment eq '1'}">
                                    <shiro:hasPermission name="cms:comment:view">
                                        <a href="${ctx}/cms/comment/?module=article&contentId=${article.id}&delFlag=2" onclick="return viewComment(this.href);">评论</a>
                                    </shiro:hasPermission>
                                </c:if>
                                <a href="${ctx}/cms/article/form?id=${article.id}">修改</a>
                                <shiro:hasPermission name="cms:article:audit">
                                    <a href="${ctx}/cms/article/delete?id=${article.id}${article.delFlag ne 0?'&isRe=true':''}&categoryId=${article.category.id}" onclick="return confirmx('确认要${article.delFlag ne 0?'发布':'删除'}该文章吗？', this.href)">${article.delFlag ne 0?'发布':'删除'}</a>
                                </shiro:hasPermission>
                            </shiro:hasPermission>
                        </td>
                    </tr>
                </c:forEach>
            </tbody>
        </table>
        <nav>${page}</nav>
    </div>
</body>
</html>